package DesignPattern.Builder.Singleton;

import java.lang.reflect.Constructor;

public class Reflex {
    public static void main(String[] args) throws Exception {
        // 获取字节码对象
        Class Clazz = TestSingleton.class;
        // 获取无参构造方法对象
        Constructor cons = Clazz.getDeclaredConstructor();
        // 取消访问检查
        cons.setAccessible(true);
        // 创建对象
        TestSingleton ts1 = (TestSingleton) cons.newInstance();
        TestSingleton ts2 = (TestSingleton) cons.newInstance();
        // false
        System.out.println(ts1 == ts2);
    }
}
